//
//  ELToothbrushBleManager.h
//  Elink
//
//  Created by iot_user on 2020/5/11.
//  Copyright © 2020 iot_iMac. All rights reserved.
//

#import "ELBluetoothManager.h"
#import "ELToothburshHeader.h"

NS_ASSUME_NONNULL_BEGIN

@protocol ToothbrushDelegate <NSObject>

@optional
//Bluetooth status callback(回调蓝牙状态)
-(void)toothbrushReceiveState:(ELBluetoothState)state;

//Callback toothbrush device list(回调牙刷设备列表)
-(void)toothbrushReceiveDevices:(NSArray<ELPeripheralModel *> *)devices;

/// Callback gear information(回调档位信息)
/// @param oneGear First gear(一档档位)
/// @param twoGear Second gear(二档档位)
-(void)toothbrushReceiveOneGear:(NSArray<NSNumber *> *)oneGear twoGear:(NSArray<NSNumber *> *)twoGear;

/// Set work gear result(设置工作档位结果)
/// @param result 结果
-(void)toothbrushReceiveSetWorkGearResult:(ELSetBluetoothResponseType)result;

//Call back current working gear information(回调当前工作档位信息)
-(void)toothbrushReceiveWorkGear:(ToothbrushWorkGear)workGear;

/// Call back trial results(回调试用结果)
/// @param result 结果
-(void)toothbrushReceiveTryResult:(ToothbrushSetResult)result;

/// Report work phase(上报工作阶段)
/// @param workPhase Work stage information(工作阶段信息)
-(void)toothbrushReceiveWorkPhase:(ToothBrushWorkPhase)workPhase;

/// Recall the data of manually set gear(回调手动设置档位的数据)
/// @param custom data(数据)
-(void)toothbrushReceiveCustomData:(ToothbrushCustomData)custom;

/// Callback switch toothbrush result(回调开关牙刷结果)
/// @param result 结果
-(void)toothbrushReceiveSwitchResult:(ToothbrushSetResult)result;


/// Callback three-axis direction(回调三轴方向)
/// @param direction 方向
-(void)toothbrushReceiveTriaxialDirection:(ToothbrushTriaxialDirection)direction;

/// Recall three-axis data(回调三轴数据)
/// @param success 是否成功
/// @param x x轴数据
/// @param y y轴数据
/// @param z z轴数据
-(void)toothbrushReceiveTriaxialData:(BOOL)success triaxialX:(int)x triaxialY:(int)y triaxialZ:(int)z;

/// Default value of second gear(二档档位默认值)
/// @param gear Second gear(二档档位)
-(void)toothbrushReceiveTwoGearDefault:(ToothbrushGearType)gear;

/// Set the second gear default gear result(设置二档默认档位结果)
/// @param result 结果
-(void)toothbrushReceiveSettingTwoGearDefaultResult:(ELSetBluetoothResponseType)result;

/// Call back brushing data(回调刷牙数据)
/// @param data 刷牙数据
-(void)toothbrushtReceiveToothbrushData:(ToothbrushData)data;

@end


@interface ELToothbrushBleManager : ELBluetoothManager
//Current working mode(当前工作模式)
@property (nonatomic, assign) ToothbrushGearType currentMode;
//Current default working hours(当前默认工作时长)
@property (nonatomic, assign) NSInteger currentWorkTime;
//Current gear(当前档位)
@property (nonatomic, assign) ToothSupportGearType currentGear;


@property (nonatomic, weak) id<ToothbrushDelegate> toothbrushDelegate;


+(instancetype)shareManager;



//Get supported gear(获取支持的档位)
-(void)getGear;

/// Set brushing mode(设置刷牙模式)
/// @param gearType Brushing mode(刷牙模式)
/// @param interval Brushing time (0: do not modify the working time, before keeping)(刷牙时间(0:不修改工作时长，保留之前))
/// @param supportType Which gear is it(是哪个档位)
-(void)setWorkGear:(ToothbrushGearType)gearType interval:(int)interval supportGearType:(ToothSupportGearType)supportType;

/// Get the current working gear(获取当前工作的档位)
-(void)getWorkGear;

/// try out(试用)
/// @param gear Gear (ToothbrushGearTypeStop means stop trial)(档位(ToothbrushGearTypeStop 表示停止试用))
/// @param supportType Which gear(第几档)
/// @param frequency 频率
/// @param duty 占空比
-(void)tryGear:(ToothbrushGearType)gear supportType:(ToothSupportGearType)supportType frequency:(int)frequency duty:(int)duty;

/// Get the current work stage(获取当前工作阶段)
-(void)getWorkPhase;

/// Set manual setting gear(设置手动设置档位)
/// @param frequency 频率
/// @param duty 占空比
/// @param interval 时间
-(void)setCustomGearData:(int)frequency duty:(int)duty interval:(int)interval;

/// Get manual profile data(获取手动设置档数据)
-(void)getCustomGear;

/// Switch toothbrush(开关牙刷)
-(void)switchToothbrush;

//Get three axis direction(获取三轴方向)
-(void)getTriaxialDirection;

//Get three-axis data(获取三轴数据)
-(void)getTriaxialData;

//Set the second gear default gear(设置二档默认档位)
-(void)setTwoGearDefaultGear:(ToothbrushGearType)gear;

//Get the second gear default gear(获取二档默认档位)
-(void)getTwoGearDefualt;

//Report the results of receiving brushing data(上报刷牙数据接收结果)
-(void)reportReceiveResultOfToothbrushData:(BOOL)result;

@end

NS_ASSUME_NONNULL_END
